package com.ruoyi.weixin.untils;

import lombok.extern.slf4j.Slf4j;

import java.util.Random;
import java.util.UUID;

@Slf4j
public final class createCode{
    public static String checkCode(String type,int len){
        StringBuilder code = new StringBuilder();
        if ("MATH".equalsIgnoreCase(type)) {
            Random random = new Random();
            for (int i = 0; i < len; i++) {
                code.append(random.nextInt(10));
            }
        } else {
            String uuid = UUID.randomUUID().toString().replaceAll("-", "");
            code = new StringBuilder(uuid.substring(0, len));
        }
        log.info("[短信服务] 生成验证码 ====> type={}, len={}, code={}", type, len, code);
        return code.toString();
    }
}